package com.lightjet.macross.base.upms.repository;

import com.lightjet.macross.base.upms.domain.ApiRules;
import com.lightjet.macross.common.core.BaseRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("apiRulesRepository")
public interface ApiRulesRepository extends BaseRepository<ApiRules, Integer> {

    @Query("select t from ApiRules t where coalesce(t.servicename,'!@$#') like :servicename " +
            "and coalesce(t.apiuri,'!@$#') like :apiuri and coalesce(t.clients,'!@$#') like :clients ")
    List<ApiRules> findByFilters(@Param("servicename") String servicename, @Param("apiuri") String apiuri, @Param("clients") String clients);

    ApiRules findByServicenameAndApiuri(String servicename, String apiuri);

    ApiRules findDistinctById(Integer id);

    List<ApiRules> findByServicenameAndIsenableAndRuletype(String servicename, byte isenable, byte ruletype);
}
